#include "qw.h"

#include <string.h>

extern char     strCodeInput[];
extern char     strCandString[];
extern int      iCodeInputCount;
extern int      iCandWordCount;
extern int      iCandPageCount;

void QWGetCandWords ()
{
    int             iQu, iWei;
    int             i;
    char            strTemp[2];

    strCandString[0] = '\0';
    strTemp[1] = '\0';

    iQu = (strCodeInput[0] - '0') * 10 + strCodeInput[1] - '0';
    iWei = (strCodeInput[2] - '0') * 10;

    for (i = 0; i < 10; i++) {
	strTemp[0] = i + '0';
	strcat (strCandString, strTemp);
	//strcat (strCandString, ".");
	strcat (strCandString, GetQuWei (iQu, iWei + i));
	strcat (strCandString, " ");
    }
}

/*
 * 区位的算法来自rfinput-2.x
 */
char           *GetQuWei (int iQu, int iWei)
{
    static char     strHZ[3];

    if (iQu >= 95) {		/* Process extend Qu 95 and 96 */
	strHZ[0] = iQu - 95 + 0xA8;
	strHZ[1] = iWei + 0x40;

	/* skip 0xa87f and 0xa97f */
	if ((unsigned char) strHZ[1] >= 0x7f)
	    strHZ[1]++;
    }
    else {
	strHZ[0] = iQu + 0xa0;
	strHZ[1] = iWei + 0xa0;
    }

    strHZ[2] = '\0';

    return strHZ;
}
